<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .container {
      width: 1200px;
      height: 600px;
    }
  </style>
</head>

<body>
  <!-- 2.定义一个具备宽高的DOM容器 -->
  <div class="container"></div>
  <!-- 1.引入echarts.js文件 -->
  <script src="./js/echarts.min.js"></script>
  <script>

    function getRandom() {
      const result = [];
      for (let index = 0; index < 7; index++) {
        result.push(Math.round(Math.random() * 100 + 50));
      }
      return result;
    }

    // 3.初始化echarts
    const myEcharts = echarts.init(document.querySelector(".container"))
    // 4.定义图片的配置项
    const option = {
      xAxis: {
        data: [
          "星期一",
          "星期二",
          "星期三",
          "星期四",
          "星期五",
          "星期六",
          "星期天",
        ]
      },
      yAxis: {
        // 是否显示坐标轴轴线
        axisLine: {
          show: true
        },
        // 是否显示坐标轴刻度
        axisTick: {
          show: true
        },
      },
      series: [
        { type: 'bar', data: getRandom() },
        { type: 'line', data: getRandom() },
        {
          type: "pie",
          data: getRandom().map((value, i) => {
            return {
              name: `数据` + (i + 1),
              value,
            };
          }),
          // 饼状图的半径（内半径和外半径）
          radius: [20, 50],
          center: ["70%", "10%"],
        },
      ]
    }
    // 5.渲染图标
    myEcharts.setOption(option)
  </script>
</body>

</html>